/**
 * @file j1939_object.h
 * @author Jomb (jomb.liu@solinftec.com)
 * @brief
 * @version 0.1
 * @date 2022-06-09
 *
 * @copyright Copyright (c) 2022
 *
 */
#ifndef J1939_OBJECT_H
#define J1939_OBJECT_H


#include "j1939_api.h"

#define J1939_UINT8_T 0
#define J1939_INT8_T 1
#define J1939_UINT16_T 2
#define J1939_INT16_T 3
#define J1939_UINT32_T 4
#define J1939_INT32_T 5

#define J1939_FLOAT_T 6
#define J1939_DOUBLE_T 7




/**
 * @brief  the struct spn
 *
 */
typedef struct
{
    unsigned int spn_num;    /* number of elements in spn */
    unsigned int start_bit;  // the object position in the frame
    unsigned int bit_len;    // length of the object
    unsigned char data_type; // type of object whether signed or unsigned
    void *factor;            // factor
    void *offset;            // offset
    void *max;               // max value of the object
    void *min;               // min value of the object
    void *object;            // the object = value from j1939 * factor + offset
    unsigned char recver;    // who that the object write, if no recver is set 0
} j1939_doubtful_object;

/**
 * @brief the struct of pgn parameters group
 *
 */
typedef struct
{

    unsigned int pgn;           // pgn of the j1939
    unsigned int b_spn_count;   // the number of spn
    j1939_doubtful_object *spn; // pointer to the spn object

} j1939_param_group;

const j1939_param_group *j1939_scan_png_group(unsigned int pgn, int *err_code, j1939_spn_callback_t **cb);

#endif
